/**
 * Created by Administrator on 2017/3/18 0018.
 */
import React from "react";
import { Checkbox } from 'antd';
import { Switch } from 'antd';

/*导出组件*/
export default class PeopleItem extends React.Component{
    constructor(props){
        super(props)
        this.state={
            ischeckde:false,
            isswitch:this.props.ele.status,
            ele : this.props.ele,
            int: 1,
            status:1
        }
        this.int = 1
        this.uid = this.props.ele.uid
    }

    componentWillMount(){
        this.setState({
            ele : this.props.ele
        });
    }

    editpeople(){
        this.props.editstaffinfo(this.state.ele.phone,this.state.ele.name,this.uid,this.state.ele.roleId,this.state.ele.email,this.state.ele.depId)
    }

    checkischose(){
        this.setState({
            ischeckde:true
        });
        this.int = 0
    }
    
    checkisunchose(){
        this.setState({
            ischeckde:false
        });
        this.int = 1
    }

    checkboxchose(e){
        let is = e.target.checked;
        if(is){
            this.setState({
                ischeckde:true,
                int:0
            });
            this.int = 0
        }else{
            this.setState({
                ischeckde:false,
                int:1
            });
            this.int = 1
        }
        this.props.isallclick(this.uid);
    }

    switchchose(e){
        this.props.forbiddenandstart(e,this.props.index,this.uid);
    }

    switchcontrol(is){
        this.setState({
            isswitch:is
        });
    }


    render(){
        return (
            <tr style={{height:"40px"}}>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}}>
                    <Checkbox style={{display:"block"}} onClick={this.checkboxchose.bind(this)} checked={this.state.ischeckde} ref={'checkbox'}/></th>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}}>{this.state.ele.name}</th>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ccc",display:"none"}}>{this.state.ele.depId}</th>

                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}}>{this.state.ele.depName}</th>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}}>{this.state.ele.roleName}</th>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}}>{this.state.ele.phone}</th>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}}>{this.state.ele.email}</th>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}} ><span className="edit_title edit_icon" style={{marginTop:10}} onClick={this.editpeople.bind(this)} /></th>
                <th style={{borderRight:"1px solid #ededed",borderBottom:"1px solid #ededed"}}><Switch checked={this.state.isswitch} onChange={this.switchchose.bind(this)}/></th>
            </tr>
        )
    }
}